package com.leetcode.June;

/**
 * @Description: 反转链表
 * @Author: Mr.Fxy
 * @CreateTime: 2024-07-08 21:57
 */
public class ReverList {
    public ListNode reverseList(ListNode head) {
        if (head == null) return null;
        ListNode cur = head, pre = null;
        while (cur != null) {
            ListNode temp = cur.next;
            cur.next = pre;//修改引用指向
            pre=cur;
            cur=temp;
        }
        return pre;
    }
}
